To be able to edit code and run cells, you need to run the notebook yourself. Where would you like to run the notebook?

This notebook takes about 3 minutes to run.

In the cloud (experimental)

Binder is a free, open source service that runs scientific notebooks in the cloud! It will take a while, usually 2-7 minutes to get a session.

On your computer

(Recommended if you want to store your changes.)

  1. Copy the notebook URL:
  2. Run Pluto

    (Also see: How to install Julia and Pluto)

  3. Paste URL in the Open box

Frontmatter

If you are publishing this notebook on the web, you can set the parameters below to provide HTML metadata. This is useful for search engines and social media.

Author 1
👀 Reading hidden code
import Pluto
26.2 s

Pluto's assets

👀 Reading hidden code
190 μs
"/home/runner/.julia/packages/Pluto/6smog/frontend-dist"
👀 Reading hidden code
dist_dir = Pluto.project_relative_path("frontend-dist")
80.9 ms
👀 Reading hidden code
dist_files = readdir(dist_dir)
185 μs
👀 Reading hidden code
local_contents = map(dist_files) do f
read(joinpath(dist_dir, f), String)
end
60.5 ms

Downloading the same assets from our CDN as reference

👀 Reading hidden code
195 μs
cdn_url (generic function with 1 method)
👀 Reading hidden code
cdn_url(filename) = "https://cdn.jsdelivr.net/gh/fonsp/Pluto.jl@$(Pluto.PLUTO_VERSION)/frontend-dist/$(filename)"
435 μs
downloaded_contents = map(dist_files) do f
read(download(cdn_url(f)), String)
end
👀 Reading hidden code
63.9 s

First output: do all files match?

👀 Reading hidden code
188 μs
using Test
👀 Reading hidden code
203 μs
matches = map(zip(dist_files, local_contents, downloaded_contents)) do (f,cl,cd)
cl == cd
end
👀 Reading hidden code
578 μs
Test Passed
  Expression: all(matches)
@test all(matches)
👀 Reading hidden code
69.7 ms

Second output: git diffs of changed files

👀 Reading hidden code
203 μs
[
diff(local_contents[i], downloaded_contents[i])
for i in eachindex(dist_files)
if !matches[i]
]
👀 Reading hidden code
45.7 μs
👀 Reading hidden code
68.1 μs
👀 Reading hidden code
67.0 μs
👀 Reading hidden code
66.3 μs

Diffing with Git.jl

👀 Reading hidden code
207 μs
using Git
👀 Reading hidden code
8.7 ms
diff (generic function with 1 method)
function diff(s1, s2)
p1 = tempname()
p2 = tempname()
write(p1, s1)
write(p2, s2)
result = IOBuffer()
try
run(pipeline(`$(git()) diff $(p1) $(p2)`; stdout=result))
catch
end
Text(String(take!(result)))
end
👀 Reading hidden code
5.2 ms
# read(`$(git()) diff --help`, String) |> Text
👀 Reading hidden code
19.4 μs

Example case:

👀 Reading hidden code
212 μs
"hello\nworld"
s1 = "hello\nworld"
👀 Reading hidden code
10.7 μs
"hello\r\nworld"
s2 = "hello\r\nworld"
👀 Reading hidden code
10.7 μs
diff --git a/tmp/jl_HIjT69 b/tmp/jl_anle1h
index 9db7df0..2930a14 100644
--- a/tmp/jl_HIjT69
+++ b/tmp/jl_anle1h
@@ -1,2 +1,2 @@
-hello
+hello
 world
\ No newline at end of file
diff(s1, s2)
👀 Reading hidden code
94.1 ms